package com.shp.utils;

import org.apache.logging.log4j.util.PropertiesUtil;

import java.io.IOException;
import java.util.Properties;

/**
 * @author ZWL
 * @Version: 1.0
 * @create: 2020/2/24 17:36
 */
public class UploadUtil {
    private static String imageAddress = null;
    private static String imageContextPath = null;
    static {
        // 创建属性集合
        Properties properties = new Properties();
        try {
            // 将配置文件properties中的键值对，保存到Properties集合
            properties.load(PropertiesUtil.class.getResourceAsStream("/upload.properties"));
            imageAddress = properties.getProperty("imagesAddress");
            imageContextPath = properties.getProperty("imageContextPath");
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    /**
     * 获取保存图片的磁盘地址
     * @return String
     */
    public static String getImagesAddress(){
        return imageAddress;
    }


    /**
     * 获取保存图片的虚拟目录
     * @return String
     */
    public static String getImageContextPath(){
        return imageContextPath;
    }



//    public static void main(String[] args) {
//        System.out.println(getImagesAddress());
//    }
}
